
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
        <meta name="description" content="">
        <meta name="author" content="">

        <title>后台</title>

        <link href="__PUBLIC__/images/favicon.ico" rel="shortcut icon" />

        <!-- Bootstrap core CSS -->
        <link rel="stylesheet" href="__PUBLIC__/css/bootstrap.min.css" />
        <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-theme.min.css" />
        <link rel="stylesheet" href="__PUBLIC__/css/dashboard.css" />
        <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-switch.css" />
        <link rel="stylesheet" href="__PUBLIC__/css/icheck/all.css" />
    </head>

    <body>

    <include file="Common/topNav" />

    <div class="container-fluid">
        <div class="row">
            <include file="Common/leftMenu" />
            <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                <div class="cont-title clearfix">
	        		<div class="title">用户组列表</div>
	        		<div class="btn-group"><button type="button" id="addRole"  class="btn">添加用户组</button></div>
	        	</div>
                
                <div class="table-responsive">

                    <table class="table table-striped table-hover" id="tableData">
                        <thead>
                            <tr>
                                <th>序号</th>
                                <th>用户组</th>
                                <th>简介</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        <volist name="roleList" id="role">
                            <tr>
                                <td>{$role.id}</td>
                                <td>{$role.name}</td>
                                <td>{$role.introduce}</td>
                                <td>
                                    <if condition="$role['status'] eq 1">
                                        <span class="label label-success">启用</span>
                                    <else />
                                        <span class="label label-danger">禁用</span>
                                    </if>
                                </td>
                            <td>
                            <if condition="$role['super'] neq 1">
                                <a href="javascript:void(0)" thisId="{$role.id}" class="editRole">修改</a> | 
                                <a href="javascript:void(0)" thisId="{$role.id}" class="delAuth">删除</a> | 
                                <a href="javascript:void(0)" thisId="{$role.id}" class="setAuth">设置权限</a>
                            </if>
                            </td>
                            </tr>
                        </volist>    
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <include file="Common/modalHtmls" />
    <script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/bootstrap-switch.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/icheck.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/validator.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
    
    <script>
        $("#tableData .setAuth").click(function () {
            var roleId = $(this).attr("thisId");
            common.htmlAjax("{:U('Admin/Role/getAuthList')}", {roleId: roleId}, function (html) {
                $("#commonModal").html(html).modal({show: true, backdrop: 'static', keyboard: false});
            })
        })
        
        $("#tableData .editRole").click(function(){
            var roleId = $(this).attr("thisId");
            //console.log(roleId);
            common.htmlAjax("{:U('Admin/Role/editRole')}", {roleId: roleId}, function (html) {
                $("#commonModal").html(html).modal({show: true, backdrop: 'static', keyboard: false});
            })
        })
        
        $("#addRole").click(function(){
            common.htmlAjax("{:U('Admin/Role/newRole')}", {}, function (html) {
                $("#commonModal").html(html).modal({show: true, backdrop: 'static', keyboard: false});
            })
        })
        
        $("#tableData .delAuth").click(function(){
            var roleId = $(this).attr("thisId");
            common.confirm("提示","确定删除用户组?",function(){
                common.ajax("{:U('Admin/Role/delRole')}",{roleId: roleId},function(data){
                    //console.log(data);
                    common.alert("提示","用户组删除成功!",function(){
                        common.reload();
                    })
                })
            })
        })
    </script>
</body>
</html>
